package com.vr.xuecheng.search.controller;

import com.vr.xuecheng.base.response.Result;
import com.vr.xuecheng.search.dto.SearchParams;
import com.vr.xuecheng.search.model.CourseIndex;
import com.vr.xuecheng.search.service.ICourseIndexService;
import com.vr.xuecheng.search.vo.SearchCoursePageVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author hzh
 * @date 2025/03/22
 * 课程索引接口
 */
@Tag(name = "课程索引接口")
@RestController
@RequestMapping("/course")
@RequiredArgsConstructor
public class CourseSearchController {
    private final ICourseIndexService courseIndexService;
    @Operation(description = "添加课程索引")
    @PostMapping("/index")
    public Result<String> addCourseIndex(@RequestBody CourseIndex courseIndex) {
        return Result.toResult(courseIndexService.addCourseIndex(courseIndex));
    }
    @Operation(description = "搜索课程")
    @GetMapping("/list")
    public SearchCoursePageVO searchCoursePage(SearchParams searchParams) {
        return courseIndexService.searchCoursePage(searchParams);
    }
}
